#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, m, a[300005], b[300005];
int pre[300005];
void sub1() {
    for(int i = 1; i <= n; i++) {
        int t = a[i];
        for(int j = 1; j <= m; j++) {
            if(t >= b[j])
                t = t + b[j];
        }
        cout << t << ' ';
    }
}
void sub2() {
    for(int i = 1; i <= n; i++) {
        int t = 0;
        int pos = 1;
        int d = -1;
        while(pos > d + 1) {
            pos = upper_bound(b, b + 1 + m, t + a[i]) - b;
            if(pos > d + 1) {
                t = pre[pos - 1];
                d = pos - 1;
                pos++;
            }
        }
        cout << t + a[i] << ' ';
    }
}
int32_t main() {
    if (fopen("luyentap.inp", "r"))
    {
        freopen("luyentap.inp", "r", stdin);
        freopen("luyentap.out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= m; i++) {
        cin >> b[i];
    }
    sort(b + 1, b + 1 + m);
    for(int i = 1; i <= m; i++)
        pre[i] = pre[i - 1] + b[i];
    sub2();
}
/*
3 4
1 1 1
1 2 3 9
*/

